hwd=$PWD
# this is absolute great testing, you can run parallel tests alongside.
# you can also check proxies online, if you want to test them go ahead
xray_dir=/root/Desktop/git_mining/xray_binaries/experiments/Xray-linux-64
python3 clear_rules.py

ps aux | grep xray | grep -v grep | grep -v sh | awk '{print $2}' | xargs -iabc kill -s KILL abc

cd json_files
tcnts=$(ls -1 | wc -l)

for ((i=0;i<$tcnts;i++));
do
	target_id=$i
	echo testing config $i
	cd $xray_dir
	./xray run -config $hwd/json_files/$target_id.json &
	pid=$!
	cd $hwd
	sleep 5
	cd proxychains_targets
	timeout 5 bash test.sh
	if [[ $? -ne 0 ]]; then
	#if [[ $? -eq 124 ]]; then
		echo has error status.
		echo cannot use proxy $i
	else
		bash check_target.sh
		if [[ $? -eq 0 ]]; then
			echo proxy $i is good
		else
			echo proxy $i has not accomplished the target.
		fi
	fi
	kill -s KILL $pid
done
